// 手机号*覆盖
// ()代表捕获组，三组都()$2就代表中间那一组数据
const maskPhoneNumber = (phone_number) => {
  const phone_pattern = /^(\d{3})\d{4}(\d{4})$/;
  return phone_number.replace(phone_pattern, "$1****$2");
};

// 千分位分隔符
const percentiles = (number = "") => {
  return number.replace(/(?!^)(?=(\d{3})+$)/g, ",");
};

// 千分位分隔并且金额前面加 ¥
const formattedPreMoney = (money, pre_money = "¥") => {
  return pre_money + money.toFixed(2).replace(/(?!^)(?=(\d{3})+$)/g, ",")
};

export { maskPhoneNumber, percentiles, formattedPreMoney };
